package com.wc.codeforces.思维.Genokraken;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/11/2 10:41
 * @description
 */
public class Main {
    /**
     * 思路；双指针, 遍历可能的父节点
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10010;
    static int[] p = new int[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            Arrays.fill(p, 1, n, 0);
            int a = 1, b = 2;
            // 找到 1 下面的节点 x, x 前面全是 0
            while (get(a, b) == 0) b++;
            p[b] = a;
            a++;
            b++;
            while (b < n) {
                while (get(a, b) == 0) a++;
                p[b] = a;
                a++;
                b++;
            }
            out.println("! ");
            for (int i = 1; i < n; i++) out.print(p[i] + " ");
            out.println();
            out.flush();
        }
    }

    static int get(int a, int b) {
        out.println("? " + a + " " + b);
        out.flush();
        int x = sc.nextInt();
        return x ^ 1;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
